import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import colors

gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))

np.random.seed(1222)

N = 50
x = np.random.rand(N)
y = np.random.rand(N)
#绘制散点图，用c值着色，
c = np.random.randn(N)
# 两种颜色之间的渐变
cmap =mpl.colors.Normalize
cmap =mpl.colors.ListedColormap(['r','g'])

area = np.pi * (15 * np.random.rand(N)) ** 2
# 颜色取值范围
norm = colors.Normalize(vmin=0, vmax=1)
plt.scatter(x, y, s=area, c=y,cmap=cmap, norm=norm, alpha=0.5)
plt.colorbar()
plt.show()
